class TouchEvents extends egret.Sprite {

    public constructor() {
        super()
        this.once( egret.Event.ADDED_TO_STAGE, this.onAddToStage, this)
    }

    private onAddToStage():void {
        let ball = new Ball()
        ball.x = 100
        ball.y = 100
        this.addChild(ball)
        ball.touchEnabled = true
        
        ball.addEventListener(egret.TouchEvent.TOUCH_BEGIN, (evt:egret.TouchEvent)=>{
            console.log("touch down ball", evt.localX, evt.localY, evt.stageX, evt.stageY)
        }, this)
        ball.addEventListener(egret.TouchEvent.TOUCH_END, (evt:egret.TouchEvent)=>{
            console.log("touch end ball", evt.localX, evt.localY, evt.stageX, evt.stageY)
        }, this)
        ball.addEventListener(egret.TouchEvent.TOUCH_MOVE, (evt:egret.TouchEvent)=>{
            console.log("touch move ball", evt.localX, evt.localY, evt.stageX, evt.stageY)
        }, this)

        this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, ()=>{
            console.log("touch down stage")
        }, this)
        this.stage.addEventListener(egret.TouchEvent.TOUCH_END, ()=>{
            console.log("touch end stage")
        }, this)
        this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, ()=>{
            console.log("touch move stage")
        }, this)
    }
}